<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>图片居中</title>
</head>
<style>
    .outer{
        width: 500px;
        height: 500px;
        border: 1px solid #000;
        /*此元素会作为一个表格单元格显示*/
        display: table-cell;
        /*设置元素的垂直对齐方式*/
        vertical-align: middle;
        text-align: center;
    }
    img{
        width: 250px;
        height: 250px;
    }
</style>
<body>
    <div class="outer">
        <img src="https://fakeimg.pl/250x100/">
    </div>
</body>
</html>
